<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="edge" />
<link rel="shortcut icon" href="static/style/images/favicon.ico" />
<!-- [EasyUI] -->
<link id="easyuiTheme" rel="stylesheet" type="text/css" href="/static/jquery-easyui-1.5.1/themes/gray/easyui.css" />
<link id="easyuiTheme" rel="stylesheet" type="text/css" href="/static/jquery-easyui-1.5.1/themes/icon.css" />
<script type="text/javascript" src="/static/js/jquery-1.10.1.min.js"></script>
<script type="text/javascript" src="/static/jquery-easyui-1.5.1/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/static/jquery-easyui-1.5.1/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="/static/js/HhUtil.js?t=20170109"></script>
<!-- [扩展样式] -->
<link rel="stylesheet" type="text/css" href="/static/css/dreamlu.css" />
<link rel="stylesheet" type="text/css" href="/static/css/icommon.css" />
<link rel="stylesheet" type="text/css" href="/static/css/login.css" />
<!--<script type="text/javascript" src="static/js/login.js" charset="utf-8"></script>-->
<title>用户管理</title>
<script type="text/javascript">

    var dataGrid;
    var flag = 1;

    $(function () {
        //用户维护（新增、修改）界面
        $("#edit_score_dialog").dialog({
            title: "积分调整",
            width: 400,
            height: 170,
            closed: true,
            cache: false,
            modal: true,
            buttons: [{
                text: '保存',
                handler: function () {
                    save_edit_score();
                }
            }, {
                text: '关闭',
                handler: function () {
                    $("#edit_score_dialog").dialog("close");
                }
            }]
        });
 	    //用户维护（新增、修改）界面
        $("#score_detail_dialog").dialog({
            title: "积分详情",
            width: 700,
            height: 600,
            closed: true,
            cache: false,
            modal: true,
            buttons: [{
                text: '关闭',
                handler: function () {
                    $("#score_detail_dialog").dialog("close");
                }
            }]
        });
        //首次进入拉取
        dataGrid = $('#dataGrid').datagrid({
            url: '/getscorelist',
            method:'get',
            fit: true,
            striped: true,
            rownumbers: true,
            singleSelect: true,
            idField: 'phone',
            pagination: true,
            pageSize: 20,
            pageList: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500],
            columns: [[{
                width: '20%',
                title: ' id',
                field: 'id',
                hidden: true
            }, {
                width: '20%',
                title: ' 用户名',
                field: 'phone'
            },{
                width: '40%',
                title: ' 用户信息',
                height: '40',
                field: 'avatar',
                formatter: function (value, row, index) {
                    var str = '';
                    str += $.formatString('<img style="height: 40px" src="{0}">', row.avatar);
                    str += $.formatString('<span>{0}</span>', row.nick_name);
                    return str;
                }
            },{
                width: '20%',
                title: '积分',
                field: 'score'
            },{
                field: 'action',
                title: '操作',
                width: '20%',
                formatter: function (value, row, index) {
                    var str = '';
                    str += $.formatString('<a href="javascript:void(0)" class="user-easyui-linkbutton-detail" data-options="plain:true,iconCls:\'icon-tip\'" onclick="score_detail(\'{0}\');" >查看详情</a>', row.phone);
                    str += $.formatString('<a href="javascript:void(0)" class="user-easyui-linkbutton-edit" data-options="plain:true,iconCls:\'icon-edit\'" onclick="edit_score(\'{0}\');" >调整积分</a>', row.phone);
                    return str;
                }} ]],
            onLoadSuccess: function (data) {
                $('.user-easyui-linkbutton-detail').linkbutton({text: '积分详情', plain: true, iconCls: 'icon-tip'});
                $('.user-easyui-linkbutton-edit').linkbutton({text: '调整积分', plain: true, iconCls: 'icon-edit'});
            },
            toolbar: '#toolbar'
        });
        });

        function searchFun() {
            dataGrid.datagrid('load', $.serializeObject($('#searchForm')));
        }


        function score_detail(phone) {
            $('#score_grid').datagrid({
                url: '/getscoredetail?phone='+phone,
                method:'get',
                fit: true,
                striped: true,
                rownumbers: true,
                singleSelect: true,
                idField: 'phone',
                pagination: true,
                pageSize: 20,
                pageList: [10, 20, 30, 40, 50, 100, 200, 300, 400, 500],
                columns: [[{
                    width: '20%',
                    title: ' id',
                    field: 'id',
                    hidden: true
                }, {
                    width: '10%',
                    title: ' ',
                    height: '40',
                    field: 'avatar',
                    formatter: function (value, row, index) {
                        var str = '';
                        str += $.formatString('<img style="height: 40px" src="{0}">', row.avatar);
                        return str;
                    }
                },{
                    width: '40%',
                    title: ' 来源',
                    field: 'desc'
                },{
                    width: '20%',
                    title: '积分',
                    field: 'score'
                },{
                    width: '20%',
                    title: '时间',
                    field: 'pubtime'
                }]],
            });
            $("#score_detail_dialog").dialog("open");
        }

        function edit_score(phone) {
            $("#edit_score_form").form("clear");
            $("#edit_score_phone").val(phone);
            $("#edit_score_dialog").dialog("open");
        }

        function save_edit_score() {
            $("#edit_score_form").form("submit", {
                url: "/changescore",
                onSumbit: function () {
                    $("#edit_score_form").form.validate();
                },
                success: function (data) {
                    data = JSON.parse(data);
                    if (data.code == "0") {
                        $("#edit_score_dialog").dialog("close");
                        HdUtil.messager.slide(data.msg);
                        $("#dataGrid").datagrid("reload");
                    } else {
                        $("#edit_score_dialog").dialog("close");
                        HdUtil.messager.error(data.msg);
                    }
                }
            });
        }




    </script>
</head>
<body class="easyui-layout" data-options="fit:true,border:false">
<div data-options="region:'north',border:false" style="height: 30px; overflow: hidden;background-color: #fff">
  <form id="searchForm">
    <table>
      <tr>
          <th>请输入手机号:</th>
          <td><input name="phone" placeholder="请输入手机号"/></td>
        <td>


          <a href="javascript:void(0);" class="easyui-linkbutton"
                       data-options="iconCls:'icon-search',plain:true" onclick="searchFun();">查询</a> </td>

      </tr>
    </table>
  </form>

</div>
<div data-options="region:'center',border:true,title:'信息列表'">
  <table id="dataGrid" data-options="fit:true,border:false">
  </table>
</div>


<div id="score_detail_dialog">
    <table id="score_grid" data-options="fit:true,border:false">
  </table>
</div>

<div id="edit_score_dialog">
    <form id="edit_score_form" method="post">
        <table>
            <tr>
                <input id="edit_score_phone" name="phone" type="hidden" />
                <td style="vertical-align: middle">类型：</td>
                <td><select data-options="required:true" class="easyui-combobox" name="type" style="width: 70px">
                    <option value="3" selected="selected">加</option>
                    <option value="4">减</option>
                </select></td>

                <td style="vertical-align: middle">调整金额：</td>
                <td><input data-options="required:true" name="score" class="easyui-textbox"/></td>

                <td style="vertical-align: middle">添加描述：</td>
                <td><input data-options="required:true" name="desc" class="easyui-textbox"/></td>
            </tr>
        </table>
    </form>
</div>
</body>
</html>
